<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>幽灵空白</title>
  <style>
    div{
      width: 600px;
      background-color: greenyellow;
    }
    img{
      height: 400px;
      /*只要不将vertical-align设置成baseline就不会出现幽灵空白的情况*/
      vertical-align: middle;
    }
  </style>
</head>
<body>
<div>
  <img src="img.png"alt="">x
</div>
</body>
</html>